package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os"
)

type Config struct {
	CompilerOptions struct {
		Module    string `json:"module"`
		Target    string `json:"target"`
		SourceMap bool   `json:"sourceMap"`
	} `json:"compilerOptions"`
	Exclude []string `json:"exclude"`
}

func main() {
	dir, err := os.Getwd()
	if err != nil {
		panic(err)
	}
	path := dir + "/config.json"
	//file, err := os.Open(path)
	//if err != nil {
	//	panic("读取配置文件发生错误")
	//}
	//defer file.Close()
	bytes, err := ioutil.ReadFile(path)
	if err != nil {
		panic("读取配置文件发生错误")
	}
	var config Config
	err = json.Unmarshal(bytes, &config)

	if err != nil {
		fmt.Println("JSON decode error!")
		return
	}

	fmt.Println(config)

	fmt.Println(config.CompilerOptions.Target)
	//println(config)

}
